Skip to content

Logs: each call to the core logged with its duration and outcome - #1902

Open
vmillet-dev wants to merge 1 commit into
logs-actionsfrom
logs-calls
Open

vmillet-dev wants to merge 1 commit into
logs-actionsfrom
logs-calls

Conversation

@vmillet-dev

Copy link
Copy Markdown
Owner

Closes #1844

Stacked on #1901 (each action logged): its base is logs-actions so that this diff is this ticket alone. Merge #1898, #1900, #1901 in that order; this pull request then targets dev/1.3.3.

Each call answers in one line. timed now wraps the three queues. db and compute time the job itself; spawn times its future. Each call is logged once at debug under ui::backend, as it answers:

DEBUG [db] ui::backend: db #412 notes::get 2 ms ok
DEBUG [devnotes-network] ui::backend: spawn #415 http::send 312 ms HttpTimeout
DEBUG [db] ui::backend: db - notes::query 4 ms ok
  • The action. Backend::as_action holds the action's number while AppState::act applies it. A call queued in that time carries #412; a call queued outside an action carries - (an answer adopted, a frame's own read). The number is read on the UI thread when the call is queued.
  • The name. It is the job's type with ui::api:: and its closures trimmed off: notes::get. A call made outside ui::api keeps its whole path (a file dialog in ui::tools::…, ui::services::updates::…).
  • The outcome. It is ok, or the error's code alone ({:?} of ErrorCode, a fieldless enum), never its detail.

Owner's decision applied. There is no slow-call warn, on any queue. A large library would make the slowest calls warn every time, and a list of exceptions would be one more thing to maintain. The debug build's « took more than 16 ms » info goes as well: every call now says its duration. As the ticket asked, no line is added in a service function.

Tests (backend::tests, real core)

  • each_call_is_logged_as_it_answers_under_the_action_that_queued_it: a db, a compute and a spawn call within an action are logged with that action's number, their name and ok. A db call outside an action is logged with -. Each line has a duration in ms.
  • a_call_is_named_by_its_api_function_and_a_failure_by_its_code_alone: api::notes::get on a closed library is logged as db - notes::get … Locked. A job failing with a sentinel title in its detail is logged with FileAccess, and the sentinel is in no line of the log.
  • The ticket's third test, a db job held past the bound and logged at warn, no longer applies: there is no bound.

Docs. The wiki's logs page gets a new section, « What the core was asked »: the line, the action's number, the name, the outcome, and why no call warns. backend.md points to that section from the queues, and testing.md's profiling paragraph drops the 16 ms line.

Checks run (Linux)

  • cargo test -p ui --lib: 1,580 pass.
  • Journey 01_first_day under Xvfb: green. Its terminal stays silent; the calls go to the e2e flavour's file only.
  • cargo clippy --workspace --all-targets --all-features -- -D warnings, cargo fmt --all --check, node scripts/architecture-links.mjs.

Generated by Claude Code

Each call, on the db, compute and spawn queues alike, is logged once at
debug as it answers, under ui::backend: its queue, the action that
queued it (Backend::as_action holds its number while AppState::act
applies it; '-' outside one), the ui::api function that asked, how long
the job ran, and ok or the error's code alone, never its detail.

The frame-bound info line of debug builds goes, and no call becomes a
warning for its duration: a large library would make the slowest calls
warn every time, and a list of exceptions is one more thing to keep.

Closes #1844

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BbVs5tCyTr9AasGra3Zzg3

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants